<template>
  <el-dropdown trigger="click" class="international" @command="handleSetLanguage">
    <div class="selectlang">
      <span v-if="languageselet=='en'"> EN</span>
      <span v-if="languageselet=='zh'"> CH</span>
    </div>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="language==='zh'" command="zh">
        中文
      </el-dropdown-item>
      <el-dropdown-item :disabled="language==='en'" command="en">
        English
      </el-dropdown-item>
      <!-- <el-dropdown-item :disabled="language==='es'" command="es">
        Español
      </el-dropdown-item>
      <el-dropdown-item :disabled="language==='ja'" command="ja">
        日本語
      </el-dropdown-item> -->
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  computed: {
    language() {
      return this.$store.getters.language
    }
  },
  data () {
    return {
      languageselet:""
    }
  },
  created(){
    this.languageselet=this.$store.getters.language
  },
  methods: {
    handleSetLanguage(lang) {
      this.languageselet= lang
      this.$i18n.locale = lang
      this.$store.dispatch('app/setLanguage', lang)
      this.$message({
        message: 'Switch Language Success',
        type: 'success'
      })
      location. reload()
    }
  }
}
</script>
<style scoped>

.selectlang{
    width: 32px;
    height: 22px;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #2489f3;
    color: #2489f3!important;
    display: flex;
    justify-content: center;
    align-items: center;
    }
</style>
